/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package agenda.model.TableModel;

import agenda.model.MdAgenda;
import java.util.Arrays;
import java.util.List;
import javax.swing.table.AbstractTableModel;

/**
 *
 * @author Julien
 */
public class AgendaTableModel extends AbstractTableModel{

    public List<MdAgenda> agendas;
    public List<String> colunas;

    public AgendaTableModel(List<MdAgenda> mdAgendas) {
        this.agendas = mdAgendas;

        this.colunas = Arrays.asList("Nome", "Sobrenome", "Telefone Fixo", "Telefone Movel");
    }

    
    @Override
    public int getRowCount() {
        return this.agendas.size();
    }

    @Override
    public int getColumnCount() {
        return this.colunas.size();
    }

    @Override
    public String getColumnName(int column) {
        return this.colunas.get(column); //To change body of generated methods, choose Tools | Templates.
    }
    
    

    @Override
    public Object getValueAt(int rowIndex, int columnIndex) {
        MdAgenda agenda = this.agendas.get(rowIndex);
        switch(columnIndex){
//            case 0: return agenda.getCodigo();
            case 0: return agenda.getNome();
            case 1: return agenda.getSobrenome();
            case 2: return agenda.getTelefoneFixo();
            case 3: return agenda.getTelefoneMovel();
                
        }
        return null;
    }
    
}
